import Request from '../static/network/request.js';

/**
 * @param { number } cid 分类id
 * @param { string } title 标题
 * @param { string } image_input 封面
 * @param { string } image_input 图片地址字符串
 * @param { string } video_path 视频链接
 * @param { string } content 内容
 * @param { string } addr 发布IP地址
 */
 
export function save(data: {
	cid?: number
	title: string
	cover_image: string
	image_input?: string
	video_path?: string
	content: string
	addr: string
	topic: string
}):any {
	return Request.post({
		api: '/api/posts/save',
		data
	})
}

export function listArticle(params: {
	page?: number
	limit?: number
	type?: number//1发布 2收藏 3赞同
	pid?: number//分类ID
	user_id?: number
}):any {
	return Request.get({
		api: '/api/posts/index',
		params
	})
}

export function infoArticle(params: {
	id: number
}):any {
	return Request.get({
		api: '/api/posts/info',
		params
	})
}


export function deleteArticle(params: {
	id: number
}):any {
	return Request.get({
		api: '/api/posts/delete',
		params
	})
}


export function getTopicList(params: {
	topic?: string
	page?: number
	limit?: number
}):any {
	return Request.get({
		api: '/api/topic/lst',
		params
	})
}

export function starArticle(params: {
	id: number
	status: number
	type: number
}):any {
	return Request.get({
		api: '/api/star',
		params
	})
}

export function collectArticle(params: {
	id: number
	status: number
}):any {
	return Request.get({
		api: '/api/collect',
		params
	})
}

export function getArticleId(params: {
	key: string
}):any {
	return Request.get({
		api: '/api/getinfobykey',
		params
	})
}

export function complaint(data: {
	type_id: number
	content: string
	image?: string
}):any {
	return Request.post({
		api: '/api/complaint/save',
		data
	})
}

export function getSearch():any {
	return Request.get({
		api: '/api/posts/hot'
	})
}